<!DOCTYPE html>
<html>

<head>
  <title>Quarkus - Using Flyway</title>
  <script id="adobe_dtm" src="https://www.redhat.com/dtm.js" type="text/javascript"></script>
  <script src="/assets/javascript/highlight.pack.js" type="text/javascript"></script>
  <META HTTP-EQUIV='Content-Security-Policy' CONTENT="default-src 'none'; script-src 'self' 'unsafe-eval' 'sha256-ANpuoVzuSex6VhqpYgsG25OHWVA1I+F6aGU04LoI+5s=' 'sha256-ipy9P/3rZZW06mTLAR0EnXvxSNcnfSDPLDuh3kzbB1w=' js.bizographics.com https://www.redhat.com assets.adobedtm.com jsonip.com https://ajax.googleapis.com https://www.googletagmanager.com https://www.google-analytics.com https://use.fontawesome.com; style-src 'self' https://fonts.googleapis.com https://use.fontawesome.com; img-src 'self' *; media-src 'self' ; frame-src https://www.googletagmanager.com https://www.youtube.com; frame-ancestors 'none'; base-uri 'none'; object-src 'none'; form-action 'none'; font-src 'self' https://use.fontawesome.com https://fonts.gstatic.com;">
  <META HTTP-EQUIV='X-Frame-Options' CONTENT="DENY">
  <META HTTP-EQUIV='X-XSS-Protection' CONTENT="1; mode=block">
  <META HTTP-EQUIV='X-Content-Type-Options' CONTENT="nosniff">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="Quarkus: Supersonic Subatomic Java">
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:site" content="@QuarkusIO"> 
  <meta name="twitter:creator" content="@QuarkusIO">
  <meta property="og:url" content="https://quarkus.io/guides/flyway" />
  <meta property="og:title" content="Quarkus - Using Flyway" />
  <meta property="og:description" content="Quarkus: Supersonic Subatomic Java" />
  <meta property="og:image" content="/assets/images/quarkus_card.png" />
  <link rel="canonical" href="https://quarkus.io/guides/flyway">
  <link rel="shortcut icon" type="image/png" href="/favicon.ico" >
  <link rel="stylesheet" href="https://quarkus.io/guides/stylesheet/config.css" />
  <link rel="stylesheet" href="/assets/css/main.css" />
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
  <link rel="alternate" type="application/rss+xml"  href="https://quarkus.io/feed.xml" title="Quarkus">
  <script src="https://quarkus.io/assets/javascript/goan.js" type="text/javascript"></script>
  <script src="https://quarkus.io/assets/javascript/hl.js" type="text/javascript"></script>
</head>

<body class="guides">
  <!-- Google Tag Manager (noscript) -->
  <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NJWS5L"
  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
  <!-- End Google Tag Manager (noscript) -->

  <div class="nav-wrapper">
  <div class="grid-wrapper">
    <div class="width-12-12">
      <input type="checkbox" id="checkbox" />
      <nav id="main-nav" class="main-nav">
  <div class="container">
    <div class="logo-wrapper">
      
        <a href="/"><img src="/assets/images/quarkus_logo_horizontal_rgb_600px_reverse.png" class="project-logo" title="Quarkus"></a>
      
    </div>
    <label class="nav-toggle" for="checkbox">
      <i class="fa fa-bars"></i>
    </label>
    <div id="menu" class="menu">
      <span>
        <a href="/get-started/" class="">Get Started</a>
      </span>
      <span>
        <a href="/guides/" class="active">Guides</a>
      </span>
      <span>
        <a href="/community/" class="">Community</a>
      </span>
      <span>
        <a href="/support/" class="">Support</a>
      </span>
      <span>
        <a href="/blog/" class="">Blog</a>
      </span>
      <span>
        <a href="https://code.quarkus.io" class="button-cta secondary white">Start Coding</a>
      </span>
    </div>
  </div>
      </nav>
    </div>
  </div>
</div>

  <div class="content">
    <div class="guide">
  <div class="width-12-12">
    <h1 class="text-caps">Quarkus - Using Flyway</h1>
    <div class="hide-mobile toc"><ul class="sectlevel1">
<li><a href="#setting-up-support-for-flyway">Setting up support for Flyway</a></li>
<li><a href="#multiple-datasources">Multiple datasources</a></li>
<li><a href="#using-the-flyway-object">Using the Flyway object</a></li>
</ul></div>
    <div>
      <div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p><a href="https://flywaydb.org/">Flyway</a> is a popular database migration tool that is commonly used in JVM environments.</p>
</div>
<div class="paragraph">
<p>Quarkus provides first class support for using Flyway as will be explained in this guide.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="setting-up-support-for-flyway"><a class="anchor" href="#setting-up-support-for-flyway"></a>Setting up support for Flyway</h2>
<div class="sectionbody">
<div class="paragraph">
<p>To start using Flyway with your project, you just need to:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>add your migrations to the <code>src/main/resources/db/migration</code> folder as you usually do with Flyway</p>
</li>
<li>
<p>activate the <code>migrate-at-start</code> option to migrate the schema automatically or inject the <code>Flyway</code> object and run
your migration as you normally do</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>In your <code>pom.xml</code>, add the following dependencies:</p>
</div>
<div class="ulist">
<ul>
<li>
<p>the Flyway extension</p>
</li>
<li>
<p>your JDBC driver extension (<code>quarkus-jdbc-postgresql</code>, <code>quarkus-jdbc-h2</code>, <code>quarkus-jdbc-mariadb</code>, &#8230;&#8203;)</p>
</li>
</ul>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="xml" class="language-xml hljs">&lt;dependencies&gt;
    &lt;!-- Flyway specific dependencies --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;io.quarkus&lt;/groupId&gt;
        &lt;artifactId&gt;quarkus-flyway&lt;/artifactId&gt;
    &lt;/dependency&gt;

    &lt;!-- JDBC driver dependencies --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;io.quarkus&lt;/groupId&gt;
        &lt;artifactId&gt;quarkus-jdbc-postgresql&lt;/artifactId&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;</code></pre>
</div>
</div>
<div class="paragraph">
<p>Flyway support relies on the Quarkus datasource config.
It can be customized for the default datasource as well as for every <a href="#multiple-datasources">named datasource</a>.
First, you need to add the datasource config to the <code>application.properties</code> file
in order to allow Flyway to manage the schema.
Also, you can customize the Flyway behaviour by using the following properties:</p>
</div>
<div class="paragraph configuration-legend">
<p><span class="icon"><i class="fa fa-lock" title="Fixed at build time"></i></span> Configuration property fixed at build time - All other configuration properties are overridable at runtime</p>
</div>
<table class="tableblock frame-all grid-all stretch configuration-reference searchable">
<colgroup>
<col style="width: 80%;">
<col style="width: 10%;">
<col style="width: 10%;">
</colgroup>
<tbody>
<tr>
<th class="tableblock halign-left valign-top"><p class="tableblock"><a id="quarkus-flyway_configuration"></a><a href="#quarkus-flyway_configuration">Configuration property</a></p></th>
<th class="tableblock halign-left valign-middle"><p class="tableblock">Type</p></th>
<th class="tableblock halign-left valign-middle"><p class="tableblock">Default</p></th>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><span class="icon"><i class="fa fa-lock" title="Fixed at build time"></i></span> <a id="quarkus-flyway_quarkus.flyway.locations"></a><code><a href="#quarkus-flyway_quarkus.flyway.locations">quarkus.flyway.locations</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Comma-separated list of locations to scan recursively for migrations. The location type is determined by its prefix.
 Unprefixed locations or locations starting with classpath: point to a package on the classpath and may contain both SQL and Java-based migrations.
 Locations starting with filesystem: point to a directory on the filesystem, may only contain SQL migrations and are only scanned recursively down non-hidden directories.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">list of string</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>db/migration</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.connect-retries"></a><code><a href="#quarkus-flyway_quarkus.flyway.connect-retries">quarkus.flyway.connect-retries</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>The maximum number of retries when attempting to connect to the database. After each failed attempt, Flyway will wait 1 second before attempting to connect again, up to the maximum number of times specified by connectRetries.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">int</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.schemas"></a><code><a href="#quarkus-flyway_quarkus.flyway.schemas">quarkus.flyway.schemas</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Comma-separated case-sensitive list of schemas managed by Flyway. The first schema in the list will be automatically set as the default one during the migration. It will also be the one containing the schema history table.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">list of string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.table"></a><code><a href="#quarkus-flyway_quarkus.flyway.table">quarkus.flyway.table</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>The name of Flyway&#8217;s schema history table. By default (single-schema mode) the schema history table is placed in the default schema for the connection provided by the datasource. When the flyway.schemas property is set (multi-schema mode), the schema history table is placed in the first schema of the list.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.sql-migration-prefix"></a><code><a href="#quarkus-flyway_quarkus.flyway.sql-migration-prefix">quarkus.flyway.sql-migration-prefix</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>The file name prefix for versioned SQL migrations. Versioned SQL migrations have the following file name structure: prefixVERSIONseparatorDESCRIPTIONsuffix , which using the defaults translates to V1.1__My_description.sql</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.repeatable-sql-migration-prefix"></a><code><a href="#quarkus-flyway_quarkus.flyway.repeatable-sql-migration-prefix">quarkus.flyway.repeatable-sql-migration-prefix</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>The file name prefix for repeatable SQL migrations. Repeatable SQL migrations have the following file name structure: prefixSeparatorDESCRIPTIONsuffix , which using the defaults translates to R__My_description.sql</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.clean-at-start"></a><code><a href="#quarkus-flyway_quarkus.flyway.clean-at-start">quarkus.flyway.clean-at-start</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>true to execute Flyway clean command automatically when the application starts, false otherwise.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>false</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.migrate-at-start"></a><code><a href="#quarkus-flyway_quarkus.flyway.migrate-at-start">quarkus.flyway.migrate-at-start</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>true to execute Flyway automatically when the application starts, false otherwise.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>false</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.baseline-on-migrate"></a><code><a href="#quarkus-flyway_quarkus.flyway.baseline-on-migrate">quarkus.flyway.baseline-on-migrate</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Enable the creation of the history table if it does not exist already.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>false</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.baseline-version"></a><code><a href="#quarkus-flyway_quarkus.flyway.baseline-version">quarkus.flyway.baseline-version</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>The initial baseline version.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.baseline-description"></a><code><a href="#quarkus-flyway_quarkus.flyway.baseline-description">quarkus.flyway.baseline-description</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>The description to tag an existing schema with when executing baseline.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.validate-on-migrate"></a><code><a href="#quarkus-flyway_quarkus.flyway.validate-on-migrate">quarkus.flyway.validate-on-migrate</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Whether to automatically call validate when performing a migration.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>false</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.out-of-order"></a><code><a href="#quarkus-flyway_quarkus.flyway.out-of-order">quarkus.flyway.out-of-order</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Allows migrations to be run "out of order".</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>false</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.create-schemas"></a><code><a href="#quarkus-flyway_quarkus.flyway.create-schemas">quarkus.flyway.create-schemas</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Whether Flyway should attempt to create the schemas specified in the schemas property</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>true</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.placeholder-prefix"></a><code><a href="#quarkus-flyway_quarkus.flyway.placeholder-prefix">quarkus.flyway.placeholder-prefix</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Prefix of every placeholder (default: ${ )</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.placeholder-suffix"></a><code><a href="#quarkus-flyway_quarkus.flyway.placeholder-suffix">quarkus.flyway.placeholder-suffix</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Suffix of every placeholder (default: } )</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><span class="icon"><i class="fa fa-lock" title="Fixed at build time"></i></span> <a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.locations"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.locations">quarkus.flyway."named-data-sources".locations</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Comma-separated list of locations to scan recursively for migrations. The location type is determined by its prefix.
 Unprefixed locations or locations starting with classpath: point to a package on the classpath and may contain both SQL and Java-based migrations.
 Locations starting with filesystem: point to a directory on the filesystem, may only contain SQL migrations and are only scanned recursively down non-hidden directories.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">list of string</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>db/migration</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.placeholders-placeholders"></a><code><a href="#quarkus-flyway_quarkus.flyway.placeholders-placeholders">quarkus.flyway.placeholders</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Sets the placeholders to replace in SQL migration scripts.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>Map&lt;String,String&gt;</code></p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">required <span class="icon"><i class="fa fa-exclamation-circle" title="Configuration property is required"></i></span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.connect-retries"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.connect-retries">quarkus.flyway."named-data-sources".connect-retries</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>The maximum number of retries when attempting to connect to the database. After each failed attempt, Flyway will wait 1 second before attempting to connect again, up to the maximum number of times specified by connectRetries.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">int</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.schemas"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.schemas">quarkus.flyway."named-data-sources".schemas</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Comma-separated case-sensitive list of schemas managed by Flyway. The first schema in the list will be automatically set as the default one during the migration. It will also be the one containing the schema history table.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">list of string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.table"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.table">quarkus.flyway."named-data-sources".table</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>The name of Flyway&#8217;s schema history table. By default (single-schema mode) the schema history table is placed in the default schema for the connection provided by the datasource. When the flyway.schemas property is set (multi-schema mode), the schema history table is placed in the first schema of the list.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.sql-migration-prefix"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.sql-migration-prefix">quarkus.flyway."named-data-sources".sql-migration-prefix</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>The file name prefix for versioned SQL migrations. Versioned SQL migrations have the following file name structure: prefixVERSIONseparatorDESCRIPTIONsuffix , which using the defaults translates to V1.1__My_description.sql</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.repeatable-sql-migration-prefix"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.repeatable-sql-migration-prefix">quarkus.flyway."named-data-sources".repeatable-sql-migration-prefix</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>The file name prefix for repeatable SQL migrations. Repeatable SQL migrations have the following file name structure: prefixSeparatorDESCRIPTIONsuffix , which using the defaults translates to R__My_description.sql</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.clean-at-start"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.clean-at-start">quarkus.flyway."named-data-sources".clean-at-start</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>true to execute Flyway clean command automatically when the application starts, false otherwise.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>false</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.migrate-at-start"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.migrate-at-start">quarkus.flyway."named-data-sources".migrate-at-start</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>true to execute Flyway automatically when the application starts, false otherwise.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>false</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.baseline-on-migrate"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.baseline-on-migrate">quarkus.flyway."named-data-sources".baseline-on-migrate</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Enable the creation of the history table if it does not exist already.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>false</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.baseline-version"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.baseline-version">quarkus.flyway."named-data-sources".baseline-version</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>The initial baseline version.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.baseline-description"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.baseline-description">quarkus.flyway."named-data-sources".baseline-description</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>The description to tag an existing schema with when executing baseline.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.validate-on-migrate"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.validate-on-migrate">quarkus.flyway."named-data-sources".validate-on-migrate</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Whether to automatically call validate when performing a migration.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>false</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.out-of-order"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.out-of-order">quarkus.flyway."named-data-sources".out-of-order</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Allows migrations to be run "out of order".</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>false</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.placeholders-placeholders"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.placeholders-placeholders">quarkus.flyway."named-data-sources".placeholders</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Sets the placeholders to replace in SQL migration scripts.</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>Map&lt;String,String&gt;</code></p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">required <span class="icon"><i class="fa fa-exclamation-circle" title="Configuration property is required"></i></span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.create-schemas"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.create-schemas">quarkus.flyway."named-data-sources".create-schemas</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Whether Flyway should attempt to create the schemas specified in the schemas property</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">boolean</p></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock"><code>true</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.placeholder-prefix"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.placeholder-prefix">quarkus.flyway."named-data-sources".placeholder-prefix</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Prefix of every placeholder (default: ${ )</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
<p><a id="quarkus-flyway_quarkus.flyway.-named-data-sources-.placeholder-suffix"></a><code><a href="#quarkus-flyway_quarkus.flyway.-named-data-sources-.placeholder-suffix">quarkus.flyway."named-data-sources".placeholder-suffix</a></code></p>
</div>
<div class="openblock description">
<div class="content">
<div class="paragraph">
<p>Suffix of every placeholder (default: } )</p>
</div>
</div>
</div></div></td>
<td class="tableblock halign-left valign-middle"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-middle"></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>The following is an example for the <code>application.properties</code> file:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs"># configure your datasource
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=sarah
quarkus.datasource.password=connor
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/mydatabase

# Flyway minimal config properties
quarkus.flyway.migrate-at-start=true

# Flyway optional config properties
# quarkus.flyway.baseline-on-migrate=true
# quarkus.flyway.baseline-version=1.0.0
# quarkus.flyway.baseline-description=Initial version
# quarkus.flyway.connect-retries=10
# quarkus.flyway.schemas=TEST_SCHEMA
# quarkus.flyway.table=flyway_quarkus_history
# quarkus.flyway.locations=db/location1,db/location2
# quarkus.flyway.sql-migration-prefix=X
# quarkus.flyway.repeatable-sql-migration-prefix=K</code></pre>
</div>
</div>
<div class="paragraph">
<p>Add a SQL migration to the default folder following the Flyway naming conventions: <code>src/main/resources/db/migration/V1.0.0__Quarkus.sql</code></p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="sql" class="language-sql hljs">CREATE TABLE quarkus
(
  id   INT,
  name VARCHAR(20)
);
INSERT INTO quarkus(id, name)
VALUES (1, 'QUARKED');</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now you can start your application and Quarkus will run the Flyway&#8217;s migrate method according to your config:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@ApplicationScoped
public class MigrationService {
    // You can Inject the object if you want to use it manually
    @Inject
    Flyway flyway; <i class="conum" data-value="1"></i><b>(1)</b>

    public void checkMigration() {
        // This will print 1.0.0
        System.out.println(flyway.info().current().getVersion().toString());
    }
}</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Inject the Flyway object if you want to use it directly</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="multiple-datasources"><a class="anchor" href="#multiple-datasources"></a>Multiple datasources</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Flyway can be configured for multiple datasources.
The Flyway properties are prefixed exactly the same way as the named datasources, for example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="properties" class="language-properties hljs">quarkus.datasource.db-kind=h2
quarkus.datasource.username=username-default
quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost/mem:default
quarkus.datasource.jdbc.min-size=3
quarkus.datasource.jdbc.max-size=13

quarkus.datasource.users.db-kind=h2
quarkus.datasource.users.username=username1
quarkus.datasource.users.jdbc.url=jdbc:h2:tcp://localhost/mem:users
quarkus.datasource.users.jdbc.min-size=1
quarkus.datasource.users.jdbc.max-size=11

quarkus.datasource.inventory.db-kind=h2
quarkus.datasource.inventory.username=username2
quarkus.datasource.inventory.jdbc.url=jdbc:h2:tcp://localhost/mem:inventory
quarkus.datasource.inventory.jdbc.min-size=2
quarkus.datasource.inventory.jdbc.max-size=12

# Flyway configuration for the default datasource
quarkus.flyway.schemas=DEFAULT_TEST_SCHEMA
quarkus.flyway.locations=db/default/location1,db/default/location2
quarkus.flyway.migrate-at-start=true

# Flyway configuration for the "users" datasource
quarkus.flyway.users.schemas=USERS_TEST_SCHEMA
quarkus.flyway.users.locations=db/users/location1,db/users/location2
quarkus.flyway.users.migrate-at-start=true

# Flyway configuration for the "inventory" datasource
quarkus.flyway.inventory.schemas=INVENTORY_TEST_SCHEMA
quarkus.flyway.inventory.locations=db/inventory/location1,db/inventory/location2
quarkus.flyway.inventory.migrate-at-start=true</code></pre>
</div>
</div>
<div class="paragraph">
<p>Notice there&#8217;s an extra bit in the key.
The syntax is as follows: <code>quarkus.flyway.[optional name.][datasource property]</code>.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Without configuration, Flyway is set up for every datasource using the default settings.
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="using-the-flyway-object"><a class="anchor" href="#using-the-flyway-object"></a>Using the Flyway object</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In case you are interested in using the <code>Flyway</code> object directly, you can inject it as follows:</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
If you enabled the <code>quarkus.flyway.migrate-at-start</code> property, by the time you use the Flyway instance,
Quarkus will already have run the migrate operation
</td>
</tr>
</table>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="java" class="language-java hljs">@ApplicationScoped
public class MigrationService {
    // You can Inject the object if you want to use it manually
    @Inject
    Flyway flyway; <i class="conum" data-value="1"></i><b>(1)</b>

    @Inject
    @FlywayDataSource("inventory") <i class="conum" data-value="2"></i><b>(2)</b>
    Flyway flywayForInventory;

    @Inject
    @Named("flyway_users") <i class="conum" data-value="3"></i><b>(3)</b>
    Flyway flywayForUsers;

    public void checkMigration() {
        // Use the flyway instance manually
        flyway.clean(); <i class="conum" data-value="4"></i><b>(4)</b>
        flyway.migrate();
        // This will print 1.0.0
        System.out.println(flyway.info().current().getVersion().toString());
    }
}</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Inject the Flyway object if you want to use it directly</td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Inject Flyway for named datasources using the Quarkus <code>FlywayDataSource</code> qualifier</td>
</tr>
<tr>
<td><i class="conum" data-value="3"></i><b>3</b></td>
<td>Inject Flyway for named datasources</td>
</tr>
<tr>
<td><i class="conum" data-value="4"></i><b>4</b></td>
<td>Use the Flyway instance directly</td>
</tr>
</table>
</div>
</div>
</div>
    </div>
  </div>
</div>

  </div>

  <div class="content project-footer">
  <div class="footer-section">
    <div class="logo-wrapper">
      <a href="/"><img src="/assets/images/quarkus_logo_horizontal_rgb_reverse.svg" class="project-logo" title="Quarkus"></a>
    </div>
  </div>
  <div class="grid-wrapper">
    <p class="grid__item width-3-12">Quarkus is open. All dependencies of this project are available under the <a href='https://www.apache.org/licenses/LICENSE-2.0' target='_blank'>Apache Software License 2.0</a> or compatible license.<br /><br />This website was built with <a href='https://jekyllrb.com/' target='_blank'>Jekyll</a>, is hosted on <a href='https://pages.github.com/' target='_blank'>Github Pages</a> and is completely open source. If you want to make it better, <a href='https://github.com/quarkusio/quarkusio.github.io' target='_blank'>fork the website</a> and show us what you’ve got.</p>

    
      <div class="width-1-12 project-links">
        <span>Navigation</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="/">Home</a></li>
          
            <li><a href="/guides">Guides</a></li>
          
            <li><a href="/community/#contributing">Contribute</a></li>
          
            <li><a href="/faq">FAQ</a></li>
          
            <li><a href="/get-started">Get Started</a></li>
          
        </ul>
      </div>
    
      <div class="width-1-12 project-links">
        <span>Contribute</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="https://twitter.com/quarkusio">Follow us</a></li>
          
            <li><a href="https://github.com/quarkusio">GitHub</a></li>
          
            <li><a href="/security">Security&nbsp;policy</a></li>
          
        </ul>
      </div>
    
      <div class="width-1-12 project-links">
        <span>Get Help</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="https://groups.google.com/forum/#!forum/quarkus-dev">Forums</a></li>
          
            <li><a href="https://quarkusio.zulipchat.com">Chatroom</a></li>
          
        </ul>
      </div>
    

    
      <div class="width-3-12 more-links">
        <span>Quarkus is made of community projects</span>
        <ul class="footer-links">
          
            <li><a href="https://vertx.io/" target="_blank">Eclipse Vert.x</a></li>
          
            <li><a href="https://microprofile.io" target="_blank">Eclipse MicroProfile</a></li>
          
            <li><a href="https://hibernate.org" target="_blank">Hibernate</a></li>
          
            <li><a href="https://netty.io" target="_blank">Netty</a></li>
          
            <li><a href="https://resteasy.github.io" target="_blank">RESTEasy</a></li>
          
            <li><a href="https://camel.apache.org" target="_blank">Apache Camel</a></li>
          
            <li><a href="https://code.quarkus.io/" target="_blank">And many more...</a></li>
          
        </ul>
      </div>
    
  </div>
</div>
  <div class="content redhat-footer">
  <div class="grid-wrapper">
    <span class="licence">
      <i class="fab fa-creative-commons"></i><i class="fab fa-creative-commons-by"></i> <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank">CC by 3.0</a> | <a href="https://www.redhat.com/en/about/privacy-policy">Privacy Policy</a>
    </span>
    <span class="redhat">
      Sponsored by
    </span>
    <span class="redhat-logo">
      <a href="https://www.redhat.com/" target="_blank"><img src="/assets/images/redhat_reversed.svg"></a>
    </span>
  </div>
</div>


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" integrity="sha384-8gBf6Y4YYq7Jx97PIqmTwLPin4hxIzQw5aDmUg/DDhul9fFpbbLcLh3nTIIDJKhx" crossorigin="anonymous"></script>
  <script type="text/javascript" src="/assets/javascript/mobile-nav.js"></script>
  <script type="text/javascript" src="/assets/javascript/scroll-down.js"></script>
  <script src="/assets/javascript/satellite.js" type="text/javascript"></script>
  <script src="https://quarkus.io/guides/javascript/config.js" type="text/javascript"></script>
  <script src="/assets/javascript/search-filter.js" type="text/javascript"></script>
  <script src="/assets/javascript/back-to-top.js" type="text/javascript"></script>
</body>

</html>
